package org.hackystat.devcathlon.ui.page.matches.browse;

import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.hackystat.devcathlon.engine.match.Match;
import org.hackystat.devcathlon.ui.DevcathlonSession;
import org.hackystat.devcathlon.ui.page.DevcathlonBasePage;
import org.hackystat.devcathlon.ui.page.matches.MatchDetailPanel;
import org.hackystat.devcathlon.ui.page.matches.browse.matchpanel.CompletedMatchPanel;
import org.hackystat.devcathlon.ui.page.matches.browse.matchpanel.MatchBrowsePanel;
import org.hackystat.devcathlon.ui.page.matches.browse.matchpanel.PendingMatchPanel;

/**
 * This page will be called when the browse match panel's match is clicked by the user.
 * 
 * @author robin
 *
 */
public class BrowseMatchDetailPage extends DevcathlonBasePage  {
  /** Support serialization. */
  private static final long serialVersionUID = 1L;

  /**
   * The constructor for the browse detail page.
   * 
   * @param mItem The match item.
   */
  public BrowseMatchDetailPage(Match mItem) {
    add(new WebMarkupContainer("body") {
      private static final long serialVersionUID = 1L;

      @Override
      public boolean isTransparentResolver() {
        return true;
      }

      @Override
      protected void onComponentTag(ComponentTag tag) {
        tag.put("class", "thrColElsHdr section-3");
      }
    });
    add(new PendingMatchPanel("pendingMatchPanel", DevcathlonSession.get().getMatchesSession()
        .getMatchNames()));
    add(new CompletedMatchPanel("completedMatchPanel", DevcathlonSession.get().getMatchesSession()
        .getMatchNames()));
    add(new MatchBrowsePanel("matchBrowsePanel", DevcathlonSession.get().getMatchesSession()
        .getMatchNames()));
    try {
      add(new MatchDetailPanel("MatchDetailPanel", mItem.getName()));
    }
    catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    
    // Make the tab corresponding to this page bold.
    get("BrowseLink").add(new SimpleAttributeModifier("class", "selected"));
  }
}